#include "linux/of.h"
#include "linux/of_fdt.h"
#include "asm/mach/arch.h"
#include "linux/printk.h"

extern struct machine_desc __arch_info_begin[], __arch_info_end[];

static void *arch_get_next_mach(char ***match)
{
    static struct machine_desc *mdesc = __arch_info_begin;
    struct machine_desc *m = mdesc;

    if (m >= __arch_info_end)
        return NULL;

    mdesc++;
    *match = m->dt_compat;
    return m;
}

struct machine_desc *setup_machine_fdt(void *dt_phys)
{
    struct machine_desc *mdesc = NULL;

    if (!dt_phys || !early_init_dt_verify(dt_phys))
        return NULL;

    mdesc = of_flat_dt_match_machine(dt_phys, arch_get_next_mach);
    if (!mdesc)
    {
    }

    if (mdesc->dt_fixup)
        mdesc->dt_fixup();

    early_init_dt_scan_nodes();

    return mdesc;
}